package com.ricervcvcer.order.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ricervcvcer.order.client.UserClient;
import com.ricervcvcer.order.entity.OrderEntity;
import com.ricervcvcer.order.mapper.OrderDao;
import com.ricervcvcer.order.mapper.OrderStatusDao;
import com.ricervcvcer.order.service.OrderService;
import com.ricervcvcer.order.util.PageUtils;
import com.ricervcvcer.order.util.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("orderService")
public class OrderServiceImpl extends ServiceImpl<OrderDao, OrderEntity> implements OrderService {

	@Autowired
	OrderStatusDao orderStatusDao;

	@Autowired
	UserClient userClient;

	@Autowired
	OrderDao orderDao;

	@Override
	public PageUtils queryPage(Map<String, Object> params) {
		IPage page = new Query().getPage(params);
		Object obj = params.get("date");
		List<String> date = (List<String>)obj;
		if(date.size() == 0) {
			params.put("dateStart",null);
			params.put("dateEnd",null);
		}
		if(date.size() != 0) {
			params.put("dateStart",date.get(0));
			params.put("dateEnd",date.get(0));
		}
		List<Map<String, Object>> search = orderDao.search(params,page );

		page.setRecords(search);

		return new PageUtils(page);
	}

}